//
//  ImagePageControl.m
//  UIControls
//
//  Created by 21CN Vgo on 12-8-1.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "ImagePageControl.h"

@interface ImagePageControl()

@end


@implementation ImagePageControl

@synthesize activeImage = _activeImage;
@synthesize inactiveImage = _inactiveImage;

// Override init.
- (id) init
{
	self = [super init];
	//self.userInteractionEnabled = NO;
	return self;
}

// Override initWithFrame.
- (id) initWithFrame:(CGRect) frame
{
	self = [super initWithFrame:frame];
	//self.userInteractionEnabled = NO;
	return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code.
}
*/

-(void)updateDots
{
    for (NSInteger i = 0; i < [self.subviews count]; i++)
    {
        UIImageView* dot = [self.subviews objectAtIndex:i];
        if (i == self.currentPage) 
		{	
			dot.image = self.activeImage;
		}
        else 
		{	
			dot.image = self.inactiveImage;
		}
    }
}

-(void) setCurrentPage:(NSInteger)page
{
	[super setCurrentPage:page];
    [self updateDots];
}


- (void)dealloc {
	SAFE_RELEASE(_activeImage);
	SAFE_RELEASE(_inactiveImage);
    [super dealloc];
}


@end
